package com.lrs.java.j2se_advanced.timer;

import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;

class TimerTest extends TimerTask{
	private int i = 0;
	public TimerTest(int i){
		this.i = i;
	}
	@Override
	public void run() {
		i = (i+1) % 2;
		System.out.println("bobing~~");
		new Timer().schedule(new TimerTest(i),2000+(2000*i));
	}
	
	public static void main(String[] args) throws Exception {
		new Timer().schedule(new TimerTest(0),2000);

		while(true){
			System.out.println("main ---------" + new Date().getSeconds());
			Thread.sleep(1000);
		}
	}
}


